/* GUI CONVERTED from socriq.p (converter v1.76) Wed Jan 23 23:00:15 2002 */
/* socriq.p - CREDIT STATUS INQUIRY                                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.14.1.7 $                                                              */
/*V8:ConvertMode=Report                                                      */
/* REVISION: 5.0      LAST MODIFIED: 03/09/90   BY: ftb   B619               */
/* REVISION: 6.0      LAST MODIFIED: 10/17/90   BY: pml  *D106*              */
/* REVISION: 6.0      LAST MODIFIED: 04/05/91   BY: bjb  *D507*              */
/* REVISION: 6.0      LAST MODIFIED: 06/12/92   BY: afs  *F607*              */
/* REVISION: 7.3      LAST MODIFIED: 11/19/92   BY: jcd  *G339*              */
/* REVISION: 7.3      LAST MODIFIED: 01/26/93   BY: tjs  *G599*              */
/* REVISION: 7.3      LAST MODIFIED: 10/25/93   BY: tjs  *GG58*              */
/* REVISION: 7.4      LAST MODIFIED: 02/21/94   BY: tjs  *H188*              */
/* REVISION: 8.5      LAST MODIFIED: 07/27/95   BY: taf  *J053*              */
/* REVISION: 7.4      LAST MODIFIED: 10/02/95   BY: jym  *G0XY*              */
/* REVISION: 8.5      LAST MODIFIED: 07/19/96   BY: taf *J0ZZ*               */
/* REVISION: 8.5      LAST MODIFIED: 04/23/97   BY: *J1LV* Aruna Patil       */
/* REVISION: 8.5      LAST MODIFIED: 08/14/97   BY: *J1Z0* Ajit Deodhar      */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane         */
/* REVISION: 8.6E     LAST MODIFIED: 15 apr 98  BY: *L00L* D. Sidel          */
/* REVISION: 8.6E     LAST MODIFIED: 05/06/98   BY: *H1JB* Niranjan R.       */
/* Old ECO marker removed, but no ECO header exists *F0PN*                   */
/* REVISION: 8.6E     LAST MODIFIED: 07/15/98   BY: *L024* Steve Goeke       */
/* REVISION: 8.6E     LAST MODIFIED: 09/28/99   BY: *L0J4* Satish Chavan     */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane  */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* myb               */
/* Revision: 1.14.1.5     BY: Katie Hilbert  DATE: 04/01/01   ECO: *P002*  */
/* Revision: 1.14.1.6     BY: Ellen Borden    DATE: 07/09/01 ECO: *P007*  */
/* $Revision: 1.14.1.7 $           BY: Ashwini G.      DATE: 01/10/02 ECO: *L194*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE socriq_p_1 "Open Amount"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define new shared variable convertmode as character no-undo
   initial "report".

define new shared variable rndmthd like rnd_rnd_mthd.
define variable oldcurr like so_curr no-undo.
define variable nbr like so_nbr.
define variable cust like so_bill.
define variable ord_date like so_ord_date.
define variable due_date like so_due_date.
define variable act_stat like so_stat.
define variable open_amt like ar_amt label {&socriq_p_1}.
define variable l_new_so like mfc_logical initial no no-undo.
define new shared variable so_recno as recid.
define new shared variable new_order      like mfc_logical initial no.
define new shared variable due_date_range like mfc_logical initial yes.
define new shared variable date_range     like sod_due_date.
define new shared variable date_range1    like sod_due_date.
define new shared variable display_trail  like mfc_logical initial no.
define new shared variable undo_trl2 like mfc_logical.

define new shared frame sotot.

{etdcrvar.i new}
{mfsotrla.i "NEW"}
{etvar.i &new = new}
{etrpvar.i &new = new}

/* ASSIGN ORIGINAL FORMAT TO _OLD VARIABLES */
assign
   nontax_old = nontaxable_amt:format
   taxable_old = taxable_amt:format
   line_tot_old = line_total:format
   disc_old     = disc_amt:format
   trl_amt_old = so_trl1_amt:format
   tax_amt_old = tax_amt:format
   ord_amt_old = ord_amt:format
   container_old = container_charge_total:format
   line_charge_old = line_charge_total:format.

oldcurr = "".


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   nbr
   cust
   ad_name  no-label format "x(20)"
   ord_date
   due_date
   act_stat
with frame a  no-underline attr-space width 80 THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

repeat:

   if ord_date = low_date then ord_date = ?.
   if due_date = low_date then due_date = ?.

   update nbr cust ord_date due_date act_stat
      with frame a
   editing:

      if frame-field = "nbr" then do:

         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i so_mstr nbr so_nbr nbr so_nbr so_nbr}

         if recno <> ? then do:
            nbr = so_nbr.
            display nbr with frame a.
            find ad_mstr where ad_addr = so_bill no-lock no-error.
            if available ad_mstr then
               display ad_addr @ cust ad_name with frame a.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.
   end.

   hide frame b.
   hide frame c.
   hide frame d.
   hide frame e.

   find cm_mstr where cm_addr = cust no-lock no-error.
   find ad_mstr where ad_addr = cust no-lock no-error.
   if available ad_mstr then display ad_name with frame a.
   else display "" @ ad_name with frame a.

   if ord_date = ? then ord_date = low_date.
   if due_date = ?  then due_date = low_date.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal" &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
               
{hksimsg.i """" """"}

   if nbr <> "" then
   for each so_mstr no-lock where (so_nbr = nbr) AND lookup(so_site,global_user_site) > 0
      with frame c down width 80:
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame c:handle).
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      /* CHECK IF ANY SALES ORDER IS BEING CREATED */
      l_new_so = no.
      {gprun.i ""sonewso.p"" "(input recid(so_mstr),
                               output l_new_so)"}
      if l_new_so then next.

      if (oldcurr <> so_curr) or (oldcurr = "") then do:

         {gprunp.i "mcpl" "p" "mc-get-rnd-mthd"
            "(input  so_curr,
              output rndmthd,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

         {socurfmt.i} /* SET CURRENCY FORMATS */
         oldcurr = so_curr.
      end. /* IF (OLDCURR <> SO_CURR) */
      assign
         maint = no
         date_range = low_date
         date_range1 = hi_date
         so_recno = recid(so_mstr).

      /* DETERMINE ord_amt */
      {gprun.i ""sosotrl2.p""}

      /* ORD_AMT IS IN DOCUMENT CURRENCY AND IS ROUNDED PER THAT CURR */
      /* IF DOC CURR AND BASE CURR ARE NOT THE SAME THEN CALCULATE ORD*/
      /* AMOUNT USING THE BASE EXCHANGE RATE AND ROUND PER BASE CURR  */
      if so_curr = base_curr then
         open_amt = ord_amt.
      else do:

         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input  so_curr,
              input  base_curr,
              input  so_ex_rate,
              input  so_ex_rate2,
              input  ord_amt,
              input  true,  /* ROUND */
              output open_amt,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

      end.

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).
      display so_bill so_nbr so_conf_date so_due_date so_ship so_cr_terms
         open_amt so_stat with frame b width 80 down STREAM-IO /*GUI*/ .
   end. /* if... for so_mstr */

   else
   if cust <> "" then
   for each so_mstr no-lock where (so_bill = cust)    and
         (so_ord_date = ord_date or ord_date = low_date) and
         (so_due_date = due_date or due_date = low_date) and
         (so_stat = act_stat or act_stat = "") AND lookup(so_site,global_user_site) > 0 with frame d down:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame d:handle).
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      if (oldcurr <> so_curr) or (oldcurr = "") then do:

         {gprunp.i "mcpl" "p" "mc-get-rnd-mthd"
            "(input  so_curr,
              output rndmthd,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

         {socurfmt.i} /* SET CURRENCY FORMATS */
         oldcurr = so_curr.
      end. /* IF (OLDCURR <> SO_CURR) */
      assign
         maint = no
         date_range = low_date
         date_range1 = hi_date
         so_recno = recid(so_mstr).

      /* DETERMINE ord_amt */
      {gprun.i ""sosotrl2.p""}

      /* ORD_AMT IS IN DOCUMENT CURRENCY AND IS ROUNDED PER THAT CURR */
      /* IF DOC CURR AND BASE CURR ARE NOT THE SAME THEN CALCULATE ORD*/
      /* AMOUNT USING THE BASE EXCHANGE RATE AND ROUND PER BASE CURR  */
      if so_curr = base_curr then
         open_amt = ord_amt.
      else do:

         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input  so_curr,
              input  base_curr,
              input  so_ex_rate,
              input  so_ex_rate2,
              input  ord_amt,
              input  true,  /* ROUND */
              output open_amt,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

      end.

      display so_bill so_nbr so_conf_date so_due_date so_ship so_cr_terms
         open_amt so_stat with frame d width 80 down STREAM-IO /*GUI*/ .
   end. /* if... for so_mstr */

   else
   for each so_mstr no-lock where (so_nbr = nbr or nbr = "") and
         (so_bill = cust or cust = "")                          and
         (so_ord_date = ord_date or ord_date = low_date)        and
         (so_due_date = due_date or due_date = low_date)        and
         (so_stat = act_stat or act_stat = "") AND  lookup(so_site,global_user_site) > 0 with frame e down:
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame e:handle).
      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


      if (oldcurr <> so_curr) or (oldcurr = "") then do:

         {gprunp.i "mcpl" "p" "mc-get-rnd-mthd"
            "(input  so_curr,
              output rndmthd,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

         {socurfmt.i} /* SET CURRENCY FORMATS */
         oldcurr = so_curr.
      end. /* IF (OLDCURR <> SO_CURR) */
      assign
         maint = no
         date_range = low_date
         date_range1 = hi_date
         so_recno = recid(so_mstr).

      /* DETERMINE ord_amt */
      {gprun.i ""sosotrl2.p""}

      /* ORD_AMT IS IN DOCUMENT CURRENCY AND IS ROUNDED PER THAT CURR */
      /* IF DOC CURR AND BASE CURR ARE NOT THE SAME THEN CALCULATE ORD*/
      /* AMOUNT USING THE BASE EXCHANGE RATE AND ROUND PER BASE CURR  */
      if so_curr = base_curr then
         open_amt = ord_amt.
      else do:

         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input  so_curr,
              input  base_curr,
              input  so_ex_rate,
              input  so_ex_rate2,
              input  ord_amt,
              input  true,  /* ROUND */
              output open_amt,
              output mc-error-number)" }
         if mc-error-number <> 0 then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         end.

      end.

      display so_bill so_nbr so_conf_date so_due_date so_ship so_cr_terms
         open_amt so_stat with frame e width 80 down STREAM-IO /*GUI*/ .
   end. /* if... for so_mstr */
   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}
end. /* repeat */
